<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace api\api\controller;


use cmf\controller\RestBaseController;
use think\response\Json;

//use AesHelper;

class LianliankkController extends RestBaseController
{
  public function index(){
      $user_id = $this->getUserId();
  }
    public function lianlianindex(){
       $encryptedData=input('encryptedData');
       var_dump($encryptedData);
        $encryptedDatadd = AesHelper::decrypt($encryptedData,"cDHcS/HkIImAqB6KYTdZg==");

        var_dump($encryptedDatadd);
        $channelId=input('channelId');
        var_dump($channelId);
        $timestamp=input('timestamp');
        var_dump($timestamp);
        $sign=input('sign');
        var_dump($sign);
    }
}
class AesHelper
{
    /*** 加密 * @param String input 加密的字符串 * @param String key 解密的 key * @return HexString */
    public static function encrypt($data, $key)
    {
        $data = openssl_encrypt($data, 'AES-128-ECB', base64_decode($key), OPENSSL_RAW_DATA);
        return base64_encode($data);
    }

    public static function decrypt($data, $key)
    {
        $encrypted = base64_decode($data);
        return openssl_decrypt($encrypted, 'AES-128-ECB', base64_decode($key), OPENSSL_RAW_DATA);
    }

    public static function getMode($key)
    {
        if (strlen($key) === 32) {
            $mode = 'AES-256-ECB';
        } elseif (strlen($key) === 24) {
            $mode = 'AES-192-ECB';
        } else {
            $mode = 'AES-128-ECB';
        }
        return $mode;
    }
}
